package com.isunland.managesystem.adapter;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.WrokRequestList.WorkRequestDetail;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import java.util.ArrayList;

//public class WorkRequestListAdapter extends BaseShadowListAdapter<WorkRequestDetail> {
//
//  public WorkRequestListAdapter(Context context, List<WorkRequestDetail> objects) {
//    super(context, objects);
//  }
//
//  public WorkRequestListAdapter(Context context, WorkRequestDetail[] objects) {
//    super(context, objects);
//  }
//
//  @Override public void bindData(int position, ViewHolder vh, WorkRequestDetail item) {
//    MyUtils.switchShadowStutus(getContext(), vh.mContentStatusTv, item.getDataStatus());
//    vh.mTitleTwoTv.setText(
//        getContext().getString(R.string.corporatPer) + item.getCooperateManName());
//    vh.mContentTwoTv.setText(
//        getContext().getString(R.string.finish_time_colon) + item.getFinishTime());
//    vh.mTitleTwoTv.setTextColor(getContext().getResources().getColor(R.color.chocolate));
//    vh.mContentTwoTv.setTextColor(getContext().getResources().getColor(R.color.chocolate));
//    vh.mContentThreeTv.setText(item.getCooperateDetails());//协作事宜
//    vh.mPersonNameTv.setText(item.getRegStaffName());
//    vh.mPersonDataTv.setText(item.getRegDate());
//  }
//}

public class WorkRequestListAdapter extends BaseButterKnifeAdapter<WorkRequestDetail> {

  public WorkRequestListAdapter(BaseVolleyActivity context, ArrayList<WorkRequestDetail> objects) {
    super(context, objects);
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_work_request;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override
  protected void initView(WorkRequestDetail item, BaseViewHolder baseHolder, int position) {
    ViewHolder holder = (ViewHolder) baseHolder;

    holder.tvTitle.setText(item.getCooperateDetails());//协作事宜
    holder.tvManName.setText(MyStringUtil.connect(context.getString(R.string.corporatPer),
        item.getCooperateManName()));//协作人
    holder.tvFinishTime.setText(MyStringUtil.connect(context.getString(R.string.requestFinishTime),
        item.getFinishTime()));//要求完成时间
    holder.tvRegStaff.setText(
        MyStringUtil.connect(item.getRegStaffName(), MyStringUtil.SEPEREATE, item.getRegDate()));
    MyUtils.switchDataStutus(context, holder.tvStatus, item.getDataStatus());
  }

  class ViewHolder extends BaseViewHolder {
    @BindView(R.id.tv_title) TextView tvTitle;
    @BindView(R.id.tv_status) TextView tvStatus;
    @BindView(R.id.tv_manName) TextView tvManName;
    @BindView(R.id.tv_finishTime) TextView tvFinishTime;
    @BindView(R.id.tv_regStaff) TextView tvRegStaff;

    ViewHolder(View view) {
      super(view);
      ButterKnife.bind(this, view);
    }
  }
}